import pinia from '../stores'
import { userInfoStore } from '../stores/userInfo'
const accessWhiteList = ['/login']
const routerGuard = (router) => {
  router.beforeEach((to, from, next) => {
    const userInfo = userInfoStore(pinia)
    if (!accessWhiteList.includes(to.path) && !userInfo.token) {
      next('/login')
    } else {
      next()
    }
  })
}

export default routerGuard
